﻿Imports Crystal.CLL

Public Class InvalidMappingDetails
    Inherits BaseForm

#Region "Fields"
    Private mdtInvalidMappings As New DataTable
    Private mdtExcelData As New DataTable
    Private mstrScreenName As String = "Invalid Mapping screen"
    Public mintProjectID As Integer
#End Region

#Region "Constructors"
    Sub New(ByVal pdtInvalidMappings As DataTable, ByVal pdtExcelData As DataTable)

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        mdtInvalidMappings = pdtInvalidMappings
        mdtExcelData = pdtExcelData
    End Sub
#End Region

#Region "On Load"

    Private Sub InvalidMappingDetails_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CallOnLoad()
    End Sub

    Private Sub CallOnLoad()
        SetOnLoadControls()
        LoadGridData()
    End Sub

    Public Sub SetOnLoadControls()
        Me.WindowState = FormWindowState.Maximized
        Me.Text = TitleManager.GetTitle("InvalidMappings")
        lblInvalidMappings.Text = MessageManager.GetMessage(DBResult.EDS_INVLDMAP_DUPMATCH_INVLD_MAP.ToString)
    End Sub

    ''' <summary>
    ''' Load the Change Mapping Log
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub LoadGridData()
        Dim ldtChangeLog As New DataTable
        Dim ldrChangeLog As IDataReader
        Try
            grdInvalidMapping.DataSource = mdtExcelData
            HideColumns()
            For Each lRow As DataRow In mdtInvalidMappings.Rows
                grdInvalidMapping.Rows(lRow.Item("RowNumber")).Hidden = False
            Next
            lblRowCount.Text = "Row Count: " + grdInvalidMapping.Rows.VisibleRowCount.ToString
        Catch ex As Exception
            Me.FormulateAndLogError(ex, mstrScreenName, mintProjectID)
        Finally
            ldtChangeLog = Nothing
            ldrChangeLog = Nothing
        End Try
    End Sub

    ''' <summary>
    ''' Hide the Map Data columns
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub HideColumns()
        grdInvalidMapping.Rows.Band.Columns("FundEntityID").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("InvEntityID").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("HasChangeLog").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("UniInvestorID").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("UniFundID").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("LinkCount").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("MInvestorTypeID").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("InvStatusCode").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("FundStatusCode").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("UniInitials").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("RowNumber").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("OriginalInvestorID").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("OriginalFundID").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("InvestorID").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("FundID").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("EntityID").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("ETemplateID").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("ClientID").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("UserID").Hidden = True
        grdInvalidMapping.Rows.Band.Columns("FilingDateCopy").Hidden = True
        grdInvalidMapping.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.True
    End Sub

#End Region

#Region "Events"

#Region "Form Events"
    Private Sub InvalidMappingDetails_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Me.Dispose()
    End Sub
#End Region

#Region "Grid Events"
    Private Sub grdInvalidMapping_InitializeRow(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles grdInvalidMapping.InitializeRow
        e.Row.Hidden = True
    End Sub
#End Region

#Region "Button Events"
    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub
#End Region

#End Region

End Class